
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include "log.h"
#include "root.h"
#include "kconfig.h"
#include "exploit.h"
#include "filelog.h"
#include "kssuenv.h"
/**
 * return 0 root 成功
 *
 *
 * */
int main(int argc, char *argv[]) {
	int rc = 0;
	root_ctx ctx;
	char log[20] = { 0 };

	int uid = 0;
	char* pszPkgName = NULL;
	char* pszRootName = NULL;

	if (argc != 4) {
		return 2;
	}

	uid = atoi(argv[1]);
	pszPkgName = argv[2];
	pszRootName = argv[3];

	LOGV("uid=%d", uid);
	LOGV("pkg=%s", pszPkgName);
	LOGV("root=%s", pszRootName);

	check_parent_pid();

	init_flog_new(NULL);

	rc = root_init(&ctx);
	if (0 <= rc) {
		rc = root_321(&ctx);
		root_free(&ctx);

		if (!rc) {
#ifdef DEBUG
			system("sh");
#else
			runrt(uid, pszPkgName, pszRootName);
#endif
			LOGR("GOT RT!");
		}
	}

	close_flog();

	return rc ? 1 : 0;
}

